{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys\n",
    "sys.path.append(r'D:\\codeproject\\data-process')\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import os \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "#用户信息表位置\n",
    "userinfo=pd.read_csv(r'D:\\学习&科研\\华为手表项目\\华为数据\\base_data\\受试者信息统计表utf8.csv')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "#计算userinfoMean(SD)\tRange\n",
    "# 计算均值、标准差和范围\n",
    "summary_stats = userinfo[['age', 'hight', 'weight']].agg(['mean', 'std', lambda x: x.max() - x.min()])\n",
    "\n",
    "# 全部数据的标准差\n",
    "summary_stats.columns = ['age', 'hight', 'weight']\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "#计算sex等于男 的值\n",
    "males_data=userinfo[userinfo['sex']=='男']\n",
    "males_summary_stats = males_data[['age', 'hight', 'weight']].agg(['mean', 'std', lambda x: x.max() - x.min()])\n",
    "\n",
    "# 全部数据的标准差\n",
    "males_summary_stats.columns = ['age', 'hight', 'weight']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "females_data=userinfo[userinfo['sex']=='女']\n",
    "females_summary_stats = females_data[['age', 'hight', 'weight']].agg(['mean', 'std', lambda x: x.max() - x.min()])\n",
    "\n",
    "# 全部数据的标准差\n",
    "females_summary_stats.columns = ['age', 'hight', 'weight']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "文件夹 D:\\学习&科研\\华为手表项目\\华为数据\\subject 及其子文件夹下有 1977 个文件\n"
     ]
    }
   ],
   "source": [
    "\n",
    "def count_files_in_directory(directory):\n",
    "    file_count = 0\n",
    "    for root, dirs, files in os.walk(directory):\n",
    "        file_count += len(files)\n",
    "    return file_count\n",
    "\n",
    "# 示例用法\n",
    "directory_path = r'D:\\学习&科研\\华为手表项目\\华为数据\\subject'\n",
    "file_count = count_files_in_directory(directory_path)\n",
    "print(f\"文件夹 {directory_path} 及其子文件夹下有 {file_count} 个文件\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "文件夹 D:\\学习&科研\\华为手表项目\\华为数据\\subject 及其子文件夹的总大小为 16.98 GB\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "\n",
    "def get_folder_size_kb(directory):\n",
    "    total_size = 0\n",
    "    for root, dirs, files in os.walk(directory):\n",
    "        for file in files:\n",
    "            file_path = os.path.join(root, file)\n",
    "            total_size += os.path.getsize(file_path)\n",
    "    return total_size / 1024/1024/1024  # 转换为 KB\n",
    "\n",
    "# 示例用法\n",
    "directory_path = r'D:\\学习&科研\\华为手表项目\\华为数据\\subject'\n",
    "folder_size_kb = get_folder_size_kb(directory_path)\n",
    "print(f\"文件夹 {directory_path} 及其子文件夹的总大小为 {folder_size_kb:.2f} GB\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "MLandDL",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.20"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
